package com.binest.figureInclusion.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.binest.kolInclusion.domain.KolInclusion;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.binest.common.annotation.Log;
import com.binest.common.core.controller.BaseController;
import com.binest.common.core.domain.AjaxResult;
import com.binest.common.enums.BusinessType;
import com.binest.figureInclusion.domain.FigureInclusion;
import com.binest.figureInclusion.service.IFigureInclusionService;
import com.binest.common.utils.poi.ExcelUtil;
import com.binest.common.core.page.TableDataInfo;

/**
 * 人物收录Controller
 * 
 * @author wwd
 * @date 2024-01-18
 */
@RestController
@RequestMapping("/figureInclusion")
public class FigureInclusionController extends BaseController
{
    @Autowired
    private IFigureInclusionService figureInclusionService;

    /**
     * 查询人物收录列表
     */
    @PreAuthorize("@ss.hasPermi('figureInclusion:figureInclusion:list')")
    @GetMapping("/list")
    public TableDataInfo list(FigureInclusion figureInclusion)
    {
        startPage();
        List<FigureInclusion> list = figureInclusionService.selectFigureInclusionList(figureInclusion);
        return getDataTable(list);
    }

    /**
     * 查询es中KOL收录列表
     */
    @GetMapping("/esList")
    public TableDataInfo esList(FigureInclusion figureInclusion) throws Exception {

        TableDataInfo list = figureInclusionService.selectFigureInclusionEsList(figureInclusion);
        return list;
    }




    /**
     * 导出人物收录列表
     */
    @PreAuthorize("@ss.hasPermi('figureInclusion:figureInclusion:export')")
    @Log(title = "人物收录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FigureInclusion figureInclusion)
    {
        List<FigureInclusion> list = figureInclusionService.selectFigureInclusionList(figureInclusion);
        ExcelUtil<FigureInclusion> util = new ExcelUtil<FigureInclusion>(FigureInclusion.class);
        util.exportExcel(response, list, "人物收录数据");
    }

    /**
     * 获取人物收录详细信息
     */
    @PreAuthorize("@ss.hasPermi('figureInclusion:figureInclusion:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(figureInclusionService.selectFigureInclusionById(id));
    }

    /**
     * 获取es中KOL收录详细信息
     */
    @GetMapping(value = "/getEsInfo")
    public AjaxResult getEsInfo(String id) throws Exception {
        return success(figureInclusionService.selectEsFigureInclusionById(id));
    }



    /**
     * 新增人物收录
     */
    @PreAuthorize("@ss.hasPermi('figureInclusion:figureInclusion:add')")
    @Log(title = "人物收录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody FigureInclusion figureInclusion)
    {
        return success(figureInclusionService.insertFigureInclusion(figureInclusion));
    }

    /**
     * 修改人物收录
     */
    @PreAuthorize("@ss.hasPermi('figureInclusion:figureInclusion:edit')")
    @Log(title = "人物收录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FigureInclusion figureInclusion)
    {
        return toAjax(figureInclusionService.updateFigureInclusion(figureInclusion));
    }

    /**
     * 删除人物收录
     */
    @PreAuthorize("@ss.hasPermi('figureInclusion:figureInclusion:remove')")
    @Log(title = "人物收录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(figureInclusionService.deleteFigureInclusionByIds(ids));
    }
}
